find_package(PkgConfig)
pkg_check_modules(PC_LZMA  liblzma)

find_path(LZMA_INCLUDE_DIRS
    NAMES lzma.h
    HINTS ${PC_LZMA_INCLUDEDIR}
    ${PC_LZMA_INCLUDE_DIRS}
)

find_library(LZMA_LIBRARIES
    NAMES lzma
    HINTS ${PC_LZMA_LIBDIR}
    ${PC_LZMA_LIBRARY_DIRS}
)
message("PC_LZMA_INCLUDEDIR=${PC_LZMA_INCLUDEDIR} PC_LZMA_INCLUDE_DIRS=${PC_LZMA_INCLUDE_DIRS}")
#message("LZMA_LIBRARIES=${LZMA_LIBRARIES} LZMA_INCLUDE_DIRS=${LZMA_INCLUDE_DIRS} PC_LZMA_VERSION=${PC_LZMA_VERSION}")
if(LZMA_INCLUDE_DIRS AND LZMA_LIBRARIES)
    set(LZMA_FOUND TRUE)
    set(LZMA_LIBRARY ${LZMA_LIBRARIES})
    set(LZMA_INCLUDE_DIR ${LZMA_INCLUDE_DIRS})
    set(LZMA_VERSION ${PC_LZMA_VERSION})
endif()

include(FindPackageHandleStandardArgs)
#FIND_PACKAGE_HANDLE_STANDARD_ARGS(zlib REQUIRED_VARS LZMA_INCLUDE_DIRS LZMA_LIBRARIES 
#	FOUND_VAR LZMA_FOUND VERSION_VAR LZMA_VERSION)

mark_as_advanced(LZMA_LIBRARIES LZMA_LIBRARY LZMA_INCLUDE_DIRS LZMA_INCLUDE_DIR LZMA_FOUND LZMA_VERSION)

